home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / world / shadow / shadow.wrl < prev    next >
Text File  |  1996-10-17  |  3KB  |  185 lines

  1. #VRML V2.0 utf8
  2. #
  3. # "Motion Shadow Effect"
  4. #     created by ask@krc.sony.co.jp (Masamichi zzzcat Asukai)
  5. #
  6. # Copyright(C) 1996 Sony Corporation. All rights reserved.
  7. #
  8.  
  9. NavigationInfo {
  10.     headlight FALSE
  11. }
  12.  
  13. Viewpoint {
  14.     position 0.0 1.75 30.0
  15. }
  16.  
  17. Background {
  18.     skyColor 0.5 0.3 0.7
  19. }
  20.  
  21. PROTO P_TREE [
  22. ] {
  23.     Billboard {
  24.         # "axisOfRotaion 0 1 0" doesn't work!
  25.         #axisOfRotaion 0 1 0
  26.         axisOfRotation 0 0 0
  27.         children [
  28.             Shape {
  29.                 appearance Appearance {
  30.                     texture ImageTexture {
  31.                         url "tree.gif"
  32.                     }
  33.                 }
  34.                 geometry IndexedFaceSet {
  35.                     coord Coordinate {
  36.                         point [
  37.                         -0.5 0 0,
  38.                          0.5 0 0,
  39.                          0.5 1 0,
  40.                         -0.5 1 0,
  41.                         ]
  42.                     }
  43.                     coordIndex [
  44.                         0, 1, 2, 3, -1,
  45.                     ]
  46.                 }
  47.             }
  48.         ]
  49.     }
  50. }
  51.  
  52. # Z value of shadow must be 1.0 in case of using shadow length
  53. PROTO P_SHADOW [
  54.     exposedField SFRotation rotation 0 1 0 0
  55.     exposedField SFVec3f scale 1 1 1
  56.     exposedField SFFloat transparency 0
  57. ] {
  58.     Transform {
  59.         rotation IS rotation
  60.         scale IS scale
  61.         children [
  62.             Shape {
  63.                 appearance Appearance {
  64.                     material Material {
  65.                         ambientIntensity 0
  66.                         diffuseColor 0 0 0
  67.                         transparency IS transparency
  68.                     }
  69.                     texture ImageTexture {
  70.                         url "tree.gif"
  71.                     }
  72.                     textureTransform TextureTransform {
  73.                         center 0.5 0.5
  74.                         rotation 3.14
  75.                     }
  76.                 }
  77.                 geometry IndexedFaceSet {
  78.                     coord Coordinate {
  79.                         point [
  80.                             -0.5 0 0,
  81.                              0.5 0 0,
  82.                              0.5 0 -1,
  83.                             -0.5 0 -1,
  84.                         ]
  85.                     }
  86.                     coordIndex [
  87.                         0, 1, 2, 3, -1,
  88.                     ]
  89.                 }
  90.             }
  91.         ]
  92.     }
  93. }
  94.  
  95. DEF TREE Transform {
  96.     translation 0 0 0
  97.     scale 3 3 3
  98.     children [
  99.         P_TREE {}
  100.         DEF SHADOW P_SHADOW {}
  101.     ]
  102. }
  103.  
  104. DEF LIGHT Transform {
  105.     translation -20 10 0
  106.     children [
  107.         PointLight {
  108.             intensity 1.0
  109.         }
  110.         Shape {
  111.             appearance Appearance {
  112.                 material Material {
  113.                     ambientIntensity 0
  114.                     diffuseColor 0 0 0
  115.                     emissiveColor 1 1 0
  116.                 }
  117.             }
  118.             geometry Sphere{
  119.                 radius 0.5
  120.             }
  121.         }
  122.     ]
  123. }
  124.  
  125. DEF L_TIME TimeSensor{
  126.     cycleInterval 10.0
  127.     stopTime -1
  128.     loop TRUE
  129. }
  130.  
  131. DEF POSINT PositionInterpolator{
  132.     set_fraction 0.5
  133.     key [0, 0.25, 0.5, 0.75, 1]
  134.     keyValue [-15 10 5, 5 15 5, 5 10 -15, -15 5 -15, -15 10 5]
  135. }
  136.  
  137. ROUTE L_TIME.fraction_changed TO POSINT.set_fraction
  138. ROUTE POSINT.value_changed TO LIGHT.set_translation
  139.  
  140.  
  141. DEF TIME TimeSensor{
  142.     cycleInterval 0.2
  143.     stopTime -1
  144.     loop TRUE
  145. }
  146.  
  147. DEF SCRIPT Script {
  148.     url "shadow.class"
  149.     eventIn SFTime interval
  150.     field SFNode light USE LIGHT
  151.     field SFNode object USE TREE
  152.     field SFNode shadow USE SHADOW
  153.     field SFBool shadow_length TRUE
  154.     field SFBool shadow_length_and_depth TRUE
  155. ROUTE TIME.cycleTime TO SCRIPT.interval
  156.  
  157.  
  158. DEF GROUND Transform {
  159.     translation 0 -0.1 0
  160.     children[
  161.         Shape {
  162.             appearance Appearance {
  163.                 material Material {
  164.                     diffuseColor 0.6 0.4 0.4
  165.                     emissiveColor 0.3 0.2 0.2
  166.                 }
  167.             }
  168.             geometry IndexedFaceSet {
  169.                 coord Coordinate {
  170.                     point [
  171.                         -30 0 -30,
  172.                         -30 0  30,
  173.                          30 0  30,
  174.                          30 0 -30,
  175.                     ]
  176.                 }
  177.                 coordIndex [
  178.                     0, 1, 2, 3, -1,
  179.                 ]
  180.             }
  181.                }
  182.     ]
  183. }
  184.